/* GUI CONVERTED from rcsqsxmt.p (converter v1.75) Tue Apr 10 12:05:58 2001 */
/* rcsqsxmt.p - SEQUENCE SCHEDLE CROSS REFERENCE MAINTENANCE FUNCTION         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.12 $                                                         */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 9.1            CREATED: 06/09/99   BY: *N003* Steve Nugent       */
/* REVISION: 9.1      LAST MODIFIED: 12/22/99   BY: *N06Z* Dan Herman         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* $Revision: 1.12 $    BY: Jean Miller          DATE: 03/22/01  ECO: *P008*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */

{mfdtitle.i}

/* ********** Begin Translatable Strings Definitions ********** */
&SCOPED-DEFINE rcsxmt_p_1 " Picked/Shipped Sequence "
/* Maxlen:50  Comment: The Customer sequence that has already been picked
                       or shipped in the system but for whatever reason
                       was not received in time or at all by the customer. */

&SCOPED-DEFINE rcsxmt_p_2 " Linked Sequence "
/* Maxlen:50  Comment: The Customer sequence that the user wants to link
                       to the picked/shipped sequence above to replace the
                       sequence that never made it to the customer */

&SCOPED-DEFINE rcsxmt_p_3 "Shipper ID"
/* Maxlen:20  Comment: The identification number of the shipper which
                       contains this sequence number */

/* ********** End Translatable Strings Definitions ********** */

/* VARIABLES */
define variable del-yn          like mfc_logical no-undo.
define variable rcsx_recid      as   recid no-undo.
define variable sequence_picked like mfc_logical initial false no-undo.
define variable shipper_id      like abss_ship_id format "x(20)"
                                label {&rcsxmt_p_3} no-undo.

/* FRAME A */

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
rcsx_shipfrom   colon 30
   rcsx_shipto     colon 60
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* FRAME B */
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
rcsx_shipped_rlse_id    colon 30
   rcsx_shipped_cust_job   colon 30
   rcsx_shipped_cust_seq   colon 30
   rcsx_shipped_part       colon 30
   rcsx_shipped_cust_ref   colon 30
   rcsx_shipped_dock       colon 30
   rcsx_shipped_line_feed  colon 30
   rcsx_shipped_date       colon 30
   rcsx_shipped_time       colon 60
   rcsx_picked             colon 16
   rcsx_shipped            colon 30
   shipper_id              colon 56
 SKIP(.4)  /*GUI*/
with frame b side-labels width 80 attr-space
 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER.
 F-b-title = (getFrameTitle("PICKED/SHIPPED_SEQUENCE",30)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame b =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame b + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5. /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

/* FRAME C */
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
rcsx_rlse_id            colon 30
   rcsx_cust_job           colon 30
   rcsx_cust_seq           colon 30
   rcsx_part               colon 30
   rcsx_cust_ref           colon 30
   rcsx_dock               colon 30
   rcsx_line_feed          colon 30
   rcsx_date               colon 30
   rcsx_time               colon 60
 SKIP(.4)  /*GUI*/
with frame c side-labels width 80 attr-space
 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-c-title AS CHARACTER.
 F-c-title = (getFrameTitle("LINKED_SEQUENCE",20)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame c = F-c-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame c =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame c + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame c =
  FRAME c:HEIGHT-PIXELS - RECT-FRAME:Y in frame c - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME c = FRAME c:WIDTH-CHARS - .5. /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame c:handle).

/* DISPLAY */
view frame a.
view frame b.

/* PROCESSING */
mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   prompt-for
      rcsx_shipfrom
      rcsx_shipto
      with frame a
   editing:

      /* FIND NEXT/PREVIOUS RECORD */
      {mfnp06.i rcsx_ref rcsx_index1
         yes
         rcsx_shipfrom
         "input rcsx_shipfrom"
         rcsx_shipto
         "input rcsx_shipto"}

      if recno <> ? then do:

         run get_shipper_id
            (input recno,
             output shipper_id).

         display
            rcsx_shipfrom
            rcsx_shipto
         with frame a.

         display
            rcsx_shipped_rlse_id
            rcsx_shipped_cust_job
            rcsx_shipped_cust_seq
            rcsx_shipped_part
            rcsx_shipped_cust_ref
            rcsx_shipped_dock
            rcsx_shipped_line_feed
            rcsx_shipped_date
            rcsx_shipped_time
            rcsx_picked
            rcsx_shipped
            substring(shipper_id,2) @ shipper_id
         with frame b.

      end. /* if recno <> ? */

   end. /* prompt-for */

   /* VALIDATE SHIP-FROM */
   for first si_mstr
   where si_site = input rcsx_shipfrom
   no-lock: end.
/*GUI*/ if global-beam-me-up then undo, leave.

   if not available si_mstr then do:
      /* Site does not exist */
      {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}
      next-prompt rcsx_shipfrom with frame a.
      undo, retry.
   end.

   {gpbrparm.i &browse=rclu104.p &parm=c-brparm1 &val=si_site}

   /* VALIDATE SHIP-TO */
   for first ad_mstr where
             ad_addr = input rcsx_shipto    and
            (ad_type = "customer" or
             ad_type = "ship-to"  or
             ad_type = "dock")
   no-lock: end.
   if not available ad_mstr then do:
      /* Ship-To does not exist */
      {pxmsg.i &MSGNUM=8501 &ERRORLEVEL=3}
      next-prompt rcsx_shipto with frame a.
      undo, retry.
   end.

   {gpbrparm.i &browse=rclu104.p &parm=c-brparm2 &val=ad_addr}

   /* ADD/EDIT/DELETE SHIPPED SEQUENCE */
   loop1:
   do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      prompt-for
         rcsx_shipped_rlse_id
         rcsx_shipped_cust_job
         rcsx_shipped_cust_seq
         rcsx_shipped_part
         rcsx_shipped_cust_ref
         rcsx_shipped_dock
         rcsx_shipped_line_feed
         rcsx_shipped_date
         rcsx_shipped_time
         with frame b
      editing:

         /* FIND NEXT/PREVIOUS RECORD */

         {mfnp06.i rcsx_ref rcsx_index1
            "rcsx_shipfrom = input frame a rcsx_shipfrom
                            and rcsx_shipto = input frame a rcsx_shipto"
            rcsx_shipfrom
            "input frame a rcsx_shipfrom"
            rcsx_shipto
            "input frame a rcsx_shipto"}

         if recno <> ? then do:

            run get_shipper_id
               (input recno,
                output shipper_id).

            display
               rcsx_shipped_rlse_id
               rcsx_shipped_cust_job
               rcsx_shipped_cust_seq
               rcsx_shipped_part
               rcsx_shipped_cust_ref
               rcsx_shipped_dock
               rcsx_shipped_line_feed
               rcsx_shipped_date
               rcsx_shipped_time
               rcsx_picked
               rcsx_shipped
               substring(shipper_id,2) @ shipper_id
            with frame b.

         end. /* if recno <> ? */
      end. /* prompt-for */

      /* DATA ENTERED MUST MATCH EXISTING rcsd_det */
      for first rcsd_det where
                rcsd_shipfrom = input rcsx_shipfrom           and
                rcsd_shipto = input rcsx_shipto               and
                rcsd_rlse_id = input rcsx_shipped_rlse_id     and
                rcsd_cust_job = input rcsx_shipped_cust_job   and
                rcsd_cust_seq = input rcsx_shipped_cust_seq   and
                rcsd_part = input rcsx_shipped_part           and
                rcsd_date = input rcsx_shipped_date           and
                rcsd_time = input rcsx_shipped_time           and
                rcsd_dock = input rcsx_shipped_dock           and
                rcsd_line_feed = input rcsx_shipped_line_feed and
                rcsd_cust_ref = input rcsx_shipped_cust_ref
      no-lock: end.
/*GUI*/ if global-beam-me-up then undo, leave.

      if not available rcsd_det then do:
         {pxmsg.i &MSGNUM=1310 &ERRORLEVEL=3} /* RECORD NOT FOUND */
         next-prompt rcsx_shipped_rlse_id with frame b.
         undo, retry.
      end.

      /* CHECK TO SEE THAT THE SEQUENCE HAS BEEN PICKED (EXISTS
      ON A SHIPPER) */
      else do:
         for first abss_det where
                   abss_shipfrom = input rcsx_shipfrom           and
                   abss_shipto = input rcsx_shipto               and
                   abss_rlse_id = input rcsx_shipped_rlse_id     and
                   abss_cust_job = input rcsx_shipped_cust_job   and
                   abss_cust_seq = input rcsx_shipped_cust_seq   and
                   abss_part = input rcsx_shipped_part           and
                   abss_date = input rcsx_shipped_date           and
                   abss_time = input rcsx_shipped_time           and
                   abss_dock = input rcsx_shipped_dock           and
                   abss_line_feed = input rcsx_shipped_line_feed and
                   abss_cust_ref = input rcsx_shipped_cust_ref
         no-lock: end.
         if not available abss_det then do:
            /*SEQUENCE HAS NOT BEEN PICKED*/
            {pxmsg.i &MSGNUM=3351 &ERRORLEVEL=3}
            next-prompt rcsx_shipped_rlse_id with frame b.
            undo, retry.
         end.
         else do:
            assign
               sequence_picked = yes.
         end. /* else do: assign */
      end. /* else do: for first abss_det */
   end. /* loop1 */

   for first rcsx_ref where
             rcsx_shipfrom = input rcsx_shipfrom                   and
             rcsx_shipto = input rcsx_shipto                       and
             rcsx_shipped_rlse_id = input rcsx_shipped_rlse_id     and
             rcsx_shipped_cust_job = input rcsx_shipped_cust_job   and
             rcsx_shipped_cust_seq = input rcsx_shipped_cust_seq   and
             rcsx_shipped_part = input rcsx_shipped_part           and
             rcsx_shipped_date = input rcsx_shipped_date           and
             rcsx_shipped_time = input rcsx_shipped_time           and
             rcsx_shipped_cust_ref = input rcsx_shipped_cust_ref   and
             rcsx_shipped_dock = input rcsx_shipped_dock           and
             rcsx_shipped_line_feed = input rcsx_shipped_line_feed
   exclusive-lock: end.

   if not available rcsx_ref then do:

      /* ADD NEW RECORD */
      {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}

      create rcsx_ref.
      assign
         rcsx_shipfrom = input rcsx_shipfrom
         rcsx_shipto = input rcsx_shipto
         rcsx_shipped_rlse_id = input rcsx_shipped_rlse_id
         rcsx_shipped_cust_job = input rcsx_shipped_cust_job
         rcsx_shipped_cust_seq = input rcsx_shipped_cust_seq
         rcsx_shipped_part = input rcsx_shipped_part
         rcsx_shipped_date = input rcsx_shipped_date
         rcsx_shipped_time = input rcsx_shipped_time
         rcsx_shipped_cust_ref = input rcsx_shipped_cust_ref
         rcsx_shipped_dock = input rcsx_shipped_dock
         rcsx_shipped_line_feed = input rcsx_shipped_line_feed
         rcsx_mod_userid = global_userid
         rcsx_mod_date = today
         rcsx_mod_pgm  = program-name(1).

      if recid(rcsx_ref) = -1 then .

   end. /* if not available rcsx_ref */

   ststatus = stline[2].
   status input ststatus.

   assign
      rcsx_recid = recid(rcsx_ref)
      del-yn = no.

   loop2:
   do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      display
         rcsx_rlse_id
         rcsx_cust_job
         rcsx_cust_seq
         rcsx_part
         rcsx_cust_ref
         rcsx_dock
         rcsx_line_feed
         rcsx_date
         rcsx_time
      with frame c.

      prompt-for
         rcsx_rlse_id
         rcsx_cust_job
         rcsx_cust_seq
         rcsx_part
         rcsx_cust_ref
         rcsx_dock
         rcsx_line_feed
         rcsx_date
         rcsx_time
         go-on("F5" "CTRL-D")
      with frame c.

      /* DELETE SEQUENCE CROSS-REFERENCE */
      if lastkey = keycode("F5") or lastkey = keycode("CTRL-D")
      then do:
         del-yn = yes.
         /* Please confirm delete */
         {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=del-yn}
         if del-yn = no then undo loop2.
      end. /* if lastkey ... */

      if del-yn = yes then do:

         for first rcsx_ref where recid(rcsx_ref) = rcsx_recid
         exclusive-lock: end.

         if available rcsx_ref then do:
            /* OK TO DELETE */
            for first rcsd_det where
                      rcsd_shipfrom = rcsx_shipfrom   and
                      rcsd_shipto = rcsx_shipto       and
                      rcsd_rlse_id = rcsx_rlse_id     and
                      rcsd_cust_job = rcsx_cust_job   and
                      rcsd_cust_seq = rcsx_cust_seq   and
                      rcsd_part = rcsx_part           and
                      rcsd_date = rcsx_date           and
                      rcsd_time = rcsx_time           and
                      rcsd_dock = rcsx_dock           and
                      rcsd_line_feed = rcsx_line_feed and
                      rcsd_cust_ref = rcsx_cust_ref
            exclusive-lock:
               assign
                  rcsd_x_referenced = no
                  rcsd_mod_userid   = global_userid
                  rcsd_mod_date     = today
                  rcsd_mod_pgm      = program-name(1).
            end.

            delete rcsx_ref.
            clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
            clear frame b.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
            clear frame c.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c = F-c-title.
            next mainloop.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* if available rcsx_ref */

      end. /* if del-yn = yes */

      for first rcsd_det where
                rcsd_shipfrom = rcsx_shipfrom   and
                rcsd_shipto = rcsx_shipto       and
                rcsd_rlse_id = rcsx_rlse_id     and
                rcsd_cust_job = rcsx_cust_job   and
                rcsd_cust_seq = rcsx_cust_seq   and
                rcsd_part = rcsx_part           and
                rcsd_date = rcsx_date           and
                rcsd_time = rcsx_time           and
                rcsd_dock = rcsx_dock           and
                rcsd_line_feed = rcsx_line_feed and
                rcsd_cust_ref = rcsx_cust_ref
      exclusive-lock:
         rcsd_x_ref = no.
      end.

      /* DATA ENTERED MUST MATCH EXISTING rcsd_det */
      for first rcsd_det where
                rcsd_shipfrom = input rcsx_shipfrom   and
                rcsd_shipto = input rcsx_shipto       and
                rcsd_rlse_id = input rcsx_rlse_id     and
                rcsd_cust_job = input rcsx_cust_job   and
                rcsd_cust_seq = input rcsx_cust_seq   and
                rcsd_part = input rcsx_part           and
                rcsd_date = input rcsx_date           and
                rcsd_time = input rcsx_time           and
                rcsd_dock = input rcsx_dock           and
                rcsd_line_feed = input rcsx_line_feed and
                rcsd_cust_ref = input rcsx_cust_ref
      exclusive-lock: end.

      if not available rcsd_det then do:
         /* Record not found */
         {pxmsg.i &MSGNUM=1310 &ERRORLEVEL=3}
         next-prompt rcsx_rlse_id with frame c.
         undo, retry.
      end.

      if rcsd_picked or rcsd_x_referenced then do:
         /* Sequence already Picked */
         {pxmsg.i &MSGNUM=2983 &ERRORLEVEL=3}
         next-prompt rcsx_rlse_id with frame c.
         undo, retry.
      end.

      assign
         rcsx_rlse_id = input rcsx_rlse_id
         rcsx_cust_job = input rcsx_cust_job
         rcsx_cust_seq = input rcsx_cust_seq
         rcsx_part = input rcsx_part
         rcsx_date = input rcsx_date
         rcsx_time = input rcsx_time
         rcsx_cust_ref = input rcsx_cust_ref
         rcsx_dock = input rcsx_dock
         rcsx_line_feed = input rcsx_line_feed.

      if sequence_picked then
      assign
         rcsx_picked = yes
         rcsx_shipped = abss_confirm.

      rcsd_x_ref = yes.

      rcsx_recid = recid(rcsx_ref).

   end.  /* loop2 */

end. /* mainloop */

PROCEDURE get_shipper_id:
/*--------------------------------------------------------------------
  Purpose:
  Parameters:
  Notes:
 ----------------------------------------------------------------------*/
   define input parameter rcsx_recid as recid no-undo.
   define output parameter shipper_id like abss_ship_id no-undo.

   for first rcsx_ref where recid(rcsx_ref) = rcsx_recid
   no-lock: end.

   if available rcsx_ref then do:

      for first abss_det where
                abss_shipfrom = rcsx_shipfrom             and
                abss_shipto = rcsx_shipto                 and
                abss_rlse_id = rcsx_shipped_rlse_id       and
                abss_cust_job = rcsx_shipped_cust_job     and
                abss_cust_seq = rcsx_shipped_cust_seq     and
                abss_part = rcsx_shipped_part             and
                abss_time = rcsx_shipped_time             and
                abss_dock = rcsx_shipped_dock             and
                abss_line_feed = rcsx_shipped_line_feed   and
                abss_cust_ref = rcsx_shipped_cust_ref
      no-lock: end.

      if available abss_det then
      assign
         shipper_id = abss_ship_id.
      else
      assign
         shipper_id = "".

   end. /* if available rcsx_ref */

END PROCEDURE.
